﻿using UnityEngine;
using System.Collections;

public class DestroyByContact : MonoBehaviour {
    public GameObject explosition;
    public GameObject playerExplosition;
    public GameObject GC;
    // Use this for initialization
    void Start () {
        GC = GameObject.Find("GameController");
	}
	
	// Update is called once per frame
	void Update () {
	
	}
    IEnumerator Delay()
    {
        yield return new WaitForSeconds(2.0f);
    }
    void OnTriggerEnter(Collider other)
    {
        GC.GetComponent<GameController>().score++;
        Instantiate(explosition, transform.position, transform.rotation);
        if (other.tag == "Player")
        {
            Instantiate(playerExplosition, other.transform.position, other.transform.rotation);
            GC.GetComponent<GameController>().isAlive = false;
            Debug.Log(GC.GetComponent<GameController>().isAlive + "");
        }
        Destroy(other.gameObject);
        Destroy(gameObject);
    }
   
}
